home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / midi / gfft.lha / gfft-2.03 / source / gfft-2.03-source.lha / gopen.c < prev    next >
C/C++ Source or Header  |  1996-01-02  |  2KB  |  45 lines

  1. /***************************************************************************
  2.  *          Copyright (C) 1994  Charles P. Peterson                  *
  3.  *         4007 Enchanted Sun, San Antonio, Texas 78244-1254             *
  4.  *              Email: Charles_P_Peterson@fcircus.sat.tx.us                *
  5.  *                                                                         *
  6.  *          This is free software with NO WARRANTY.                  *
  7.  *          See gfft.c, or run program itself, for details.              *
  8.  *              Support is available for a fee.                      *
  9.  ***************************************************************************
  10.  *
  11.  * Program:     gfft--General FFT analysis
  12.  * File:        gopen.c
  13.  * Purpose:     Open a file (using provided path list)
  14.  * Author:      Charles Peterson (CPP)
  15.  * History:     13-September-1993 CPP; Created.
  16.  *              13-January-1995 CPP (1.19) use <string.h> for ANSI compat
  17.  * Comments:    
  18.  */
  19.  
  20. #include <stdio.h>
  21. #include <string.h>
  22. #include "gfft.h"
  23.  
  24. void *gopen (char *path_list[], char *filename, char *mode)
  25. {
  26.     FILE *file = NULL;
  27.     char full_filename [MAX_PATH];
  28.     int path_index = 0;
  29.  
  30.     while (!file)
  31.     {
  32.     if (!path_list[path_index]) break;
  33.     if (strlen (path_list[path_index]) + strlen (filename) + 1 > 
  34.         MAX_PATH)
  35.     {
  36.         error_message (FILENAME_TOO_LONG);
  37.     }
  38.     strcpy (full_filename, path_list[path_index]);
  39.     strcat (full_filename, filename);
  40.     file = fopen (full_filename, mode);
  41.     path_index++;
  42.     }    
  43.     return file;
  44. }
  45.